Page({  
  data: {  
    breakRuleRecords: [  
      { 
        create_time: '2023-07-01', 
        floorIndex:1,
        datePosition:2,
        timeId:3,
        area:4,
        id: '130-20',
        remark:'未签到',
        status:'2',
      },  
      {
        floorIndex:1,
        datePosition:2,
        timeId:3,
        area:4,
        create_time: '2023-07-02', 
        remark:'早退',
        status:'2'},  
        { 
          create_time: '2023-07-03', 
          floorIndex:1,
          datePosition:2,
          timeId:3,
          area:4,
          id: '130-20',
          remark:'正常签到',
          status:'1'
        },
    ],

    list: [],
    user_id:"",

  time: [
      "8:00",
      "9:00",
      "10:00",
      "11:00",
      "12:00",
      "13:00",
      "14:00",
      "15:00",
      "16:00",
      "17:00",
      "18:00",
      "19:00",
      "20:00",
      "21:00"
    ],
  Time: [
      "8:00-9:00",
      "9:00-10:00",
      "10:00-11:00",
      "11:00-12:00",
      "12:00-13:00",
      "13:00-14:00",
      "14:00-15:00",
      "15:00-16:00",
      "16:00-17:00",
      "17:00-18:00",
      "18:00-19:00",
      "19:00-20:00",
      "20:00-21:00",
    ], 
  Area: [
      "1号位",
      "2号位",
      "3号位",
      "4号位",
      "5号位",
      "6号位",
      "7号位",
      "8号位",
      "9号位",
      "10号位",
      "11号位",
      "12号位",
      "13号位",
      "14号位",
      "15号位",
      "16号位",
    ],
  date: [
      '星期一',
      '星期二',
      '星期三',
      '星期四',
      '星期五',
      '星期六',
      '星期天',
    ],
  floor: ['1楼','2楼','3楼','4楼','5楼','6楼'],

  },  

 onLoad(options){
  let username = wx.getStorageSync('username')
  this.setData({
    user_id:username
  });
  var day_type=new Date().getDay()-1
  if(day_type == -1){
    day_type = 6
  }
  console.log("收到的用户名为：",this.data.user_id)
  wx.request({
    url: "http://localhost:9090/api/userInfo/seatAll/getByUserId", 
    data :{
      user_id:this.data.user_id,
    },
    success:(res)=>{
      console.log(res.data.data)
      let breakRecords=[]
      if(res.data.data.length){
        let record=res.data.data
        console.log(record)
        for(let i=0;i<record.length;i++){
          var temp = record[i].information.split(",");
          let oneRecord={};
          oneRecord.floorIndex=temp[0]
          oneRecord.datePosition=temp[1]
          oneRecord.timeId=temp[2]
          oneRecord.area=temp[3]
          oneRecord.remark=record[i].remark
          oneRecord.create_time=record[i].createtime
          oneRecord.status=record[i].status
          breakRecords.push(oneRecord)
        }
        this.setData({
          breakRuleRecords:breakRecords
        })
      } else{
        this.setData({
          breakRuleRecords:[]
        })
      }
      
    },

    fail:(res)=>{
      console.log("获取失败")
    }
  }) 
 }

});